//
//  GCMAddTaskViewController.m
//  GeeCityManager
//
//  Created by 聚城科技 on 16/3/22.
//  Copyright © 2016年 聚城科技. All rights reserved.
//

#import "GCMAddTaskViewController.h"
#import "HJDatePickerView.h"
#import "GCMSLRViewController.h"
#import "GCMAboutTaskModel.h"


@interface GCMAddTaskViewController ()<UIScrollViewDelegate,UIAlertViewDelegate>

@end

@implementation GCMAddTaskViewController{

    UITextField *_textF;
    UIButton * _leftbutton;
    UIButton * _rightbutton;
    NSMutableArray *_reciveFenleiArray;
    NSMutableArray *_reciveXiaoquArray;
    NSMutableArray *_yearArr;
    NSMutableArray *_monthArr;
    NSMutableArray *_yearArr1;
    NSMutableArray *_monthArr1;
    UIScrollView *_scrollV;
    UIButton *_SLRBtn;
    UILabel *_SLRLabel;
    UITextField *_textFZR;
    UITextField *_textDSF;
    UITextView *_textFMS;
    UIButton *_overTimeBtn1;
    UIButton *_overTimeBtn2;
    UIButton *_pgTimeBtn1;
    UIButton *_pgTimeBtn2;
    UIButton *_Submit;
    NSString *_timestr;
    
    UIButton *doneButton;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createScrollView];
    [self downLoadData];
    //[self createUI];
    // Do any additional setup after loading the view from its nib.
}

-(void)createScrollView{
    
    //    创建可以滑动的视图
    _scrollV = [[UIScrollView alloc]initWithFrame:CGRectMake(5, 69, SCREEN_WIDTH - 10, SCREEN_HEIGHT - 64 - 5)];
    _scrollV.delegate = self;
    _scrollV.alwaysBounceHorizontal = NO;
    _scrollV.alwaysBounceVertical = NO;
    _scrollV.showsHorizontalScrollIndicator = NO;
    _scrollV.showsVerticalScrollIndicator = NO;
    _scrollV.bounces = NO;
    _scrollV.contentOffset = CGPointMake(0, 0);
    _scrollV.contentSize = CGSizeMake(SCREEN_WIDTH - 10, SCREEN_HEIGHT + 100);
    _scrollV.backgroundColor = [UIColor colorWithRed:.95 green:.95 blue:.95 alpha:1.0];
    _scrollV.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self.view addSubview:_scrollV];
    
//    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapScrollerview)];
//    tap.cancelsTouchesInView = NO;
//    [_scrollV addGestureRecognizer:tap];
}


-(void)downLoadData{

    //    请求左按钮的分类数据
    [GCMReviceHttpRequst postFenLeiDataWithURL:TASKTYPE_URL Success:^(id obj, NSError *err) {
        //NSLog(@"%@",obj);
        _reciveXiaoquArray = [NSMutableArray arrayWithArray:obj];
        //NSLog(@"12345%@",_reciveXiaoquArray);
        
        
            //    请求又按钮的分类数据
        [GCMReviceHttpRequst postFenLeiDataWithURL:TASKLEVEL_URL Success:^(id obj, NSError *err) {
            _reciveFenleiArray = [NSMutableArray arrayWithArray:obj];
            //NSLog(@"4321%@",_reciveFenleiArray);
            [self createUI];
        }];
       
    }];

    

  

}

-(void)createUI{
    
    //self.view.backgroundColor = [UIColor grayColor];
    CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
    CGColorRef color = CGColorCreate(colorSpaceRef, (CGFloat[]){0.98,0.98,0.98,1});
    _textF = [[UITextField alloc]initWithFrame:CGRectMake(20, 10, SCREEN_WIDTH - 40, 40)];
    _textF.placeholder = @"请填写任务主题";
    _textF.text = [self.taskAboutArray valueForKey:@"content"];
    [_scrollV addSubview:_textF];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(20, 50, SCREEN_WIDTH - 40, 2)];
    label.backgroundColor = [UIColor orangeColor];
    [_scrollV addSubview:label];
//    添加类型和级别
    UILabel *leixingLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 60, 40, 50)];
    //leixingLabel.backgroundColor = [UIColor redColor];
    leixingLabel.text = @"类型:";
    leixingLabel.textColor = [UIColor redColor];
    [_scrollV addSubview:leixingLabel];
    UILabel *jiebieLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2 +10, 60, 40, 50)];
    //leixingLabel.backgroundColor = [UIColor redColor];
    jiebieLabel.text = @"级别:";
    jiebieLabel.textColor = [UIColor redColor];
    [_scrollV addSubview:jiebieLabel];
    
    _leftbutton = [[UIButton alloc] initWithFrame:CGRectMake(50, 60, (SCREEN_WIDTH - 100)/2, 50)];
    _rightbutton = [[UIButton alloc] initWithFrame:CGRectMake((SCREEN_WIDTH )/2 +50    , 60, (SCREEN_WIDTH - 100)/2 , 50)];
    _leftbutton.titleEdgeInsets = UIEdgeInsetsMake(0, -30, 0, 0);
    _rightbutton.titleEdgeInsets = UIEdgeInsetsMake(0, -30, 0, 0);//设置title在button上的位置（上top，左left，下bottom，右right）
    [_leftbutton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [_leftbutton setTitle:@"小区" forState:UIControlStateNormal];
    [_rightbutton setTitle:@"我的全部接待" forState:UIControlStateNormal];
    //[_leftbutton setBackgroundColor:[UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1]];
    //[_rightbutton setBackgroundColor:[UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1]];
    [_rightbutton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    UIImageView *rimageViwe = [[UIImageView alloc]initWithFrame:CGRectMake((SCREEN_WIDTH  - 100)/ 2 - 40, 10, 30, 30)];
    [rimageViwe setImage:[UIImage imageNamed:@"xiala"]];
    [_rightbutton addSubview:rimageViwe];
    UIImageView *limageViwe = [[UIImageView alloc]initWithFrame:CGRectMake((SCREEN_WIDTH  - 100)/ 2 - 30, 10, 30, 30)];
    [limageViwe setImage:[UIImage imageNamed:@"xiala"]];
    [_leftbutton addSubview:limageViwe];
//    [_leftbutton.layer setBorderWidth:1.f];
//    [_leftbutton.layer setBorderColor:color];
//    [_leftbutton.layer setCornerRadius:0];
//    [_rightbutton.layer setBorderColor:color];
//    [_rightbutton.layer setBorderWidth:1.f];
//    [_rightbutton.layer setCornerRadius:0];
    [_leftbutton addTarget:self action:@selector(onLeftbutton) forControlEvents:UIControlEventTouchUpInside];
    [_rightbutton addTarget:self action:@selector(onRightbutton) forControlEvents:UIControlEventTouchUpInside];
    [_scrollV addSubview:_leftbutton];
    [_scrollV addSubview:_rightbutton];
    //_yearArr = [NSMutableArray arrayWithObjects:[NSString stringWithFormat:@"%d",[dastr intValue]-1],dastr, nil];
    NSMutableArray *fenleiA = [[NSMutableArray alloc]init];
    NSMutableArray *fenleiB = [[NSMutableArray alloc]init];
    NSMutableArray *fenleiA1 = [[NSMutableArray alloc]init];
    NSMutableArray *fenleiB1 = [[NSMutableArray alloc]init];
    //NSLog(@"zou%@",_reciveFenleiArray);
    for (NSDictionary *dic in _reciveFenleiArray) {
        NSString *str =[ NSString stringWithFormat:@"%@", [dic valueForKey:@"name"] ];
        [fenleiA addObject:str];
        _monthArr = [NSMutableArray arrayWithArray:fenleiA];
        NSString *str1 =[ NSString stringWithFormat:@"%@", [dic valueForKey:@"id"] ];
        [fenleiA1 addObject:str1];
        _monthArr1 = [NSMutableArray arrayWithArray:fenleiA1];
        _leftbutton.tag = [[_reciveFenleiArray[0] valueForKey:@"id"] intValue];
    }
    
    NSLog(@"you%@",_reciveXiaoquArray);
    NSLog(@"you%@",_reciveFenleiArray);
    
    for (NSDictionary *dic1 in _reciveXiaoquArray) {
        NSString *str =[ NSString stringWithFormat:@"%@", [dic1 valueForKey:@"name"] ];
        [fenleiB addObject:str];
        _yearArr = [NSMutableArray arrayWithArray:fenleiB];
        NSString *a= [dic1 valueForKey:@"id"] ;
        [fenleiB1 addObject:a];
        _yearArr1 = [NSMutableArray arrayWithArray:fenleiB1];
        _rightbutton.tag = [[_reciveXiaoquArray[0] valueForKey:@"id"] intValue];
    }
    
    [_leftbutton setTitle:_yearArr[0] forState:UIControlStateNormal];
    [_rightbutton setTitle:_monthArr[0] forState:UIControlStateNormal];
    
    _SLRBtn = [[UIButton alloc]initWithFrame:CGRectMake(10, _leftbutton.frame.origin.y + 60, SCREEN_WIDTH - 20, 40)];
    [_SLRBtn addTarget:self action:@selector(onSLRBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [_scrollV addSubview:_SLRBtn];
    UILabel *slrLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, (SCREEN_WIDTH - 20) /2 +20, 40)];
    slrLabel.text = @"请选择受理人(必填):";
    slrLabel.textColor  = [UIColor redColor];
    
    [_SLRBtn addSubview:slrLabel];
    _SLRLabel = [[UILabel alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 20) /2, 0, (SCREEN_WIDTH - 20) /2, 40)];
    _SLRLabel.text = @"";
    //_SLRLabel.textColor  = [UIColor redColor];
    _SLRLabel.textAlignment = NSTextAlignmentCenter;
    [_SLRBtn addSubview:_SLRLabel];
    
    UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(_SLRBtn.bounds.size.width - 40, 0, 40, 40)];
    [imageV setImage:[UIImage imageNamed:@"common_ic_arrow_right"]];
    [_SLRBtn addSubview:imageV];
    
    _textFZR = [[UITextField alloc]initWithFrame:CGRectMake(20, 160, SCREEN_WIDTH - 40, 50)];
    _textFZR.placeholder = @"请填写责任单位";
    _textFZR.tag = 5331;
    [_scrollV addSubview:_textFZR];
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 210, SCREEN_WIDTH - 20, 1)];
    label1.layer.borderWidth = 1;
    label1.layer.borderColor = [[ UIColor lightGrayColor]CGColor];
    [_scrollV addSubview:label1];
    _textDSF = [[UITextField alloc]initWithFrame:CGRectMake(20, 210, SCREEN_WIDTH - 40, 50)];
    _textDSF.tag = 5332;
    _textDSF.placeholder = @"请填写第三方处理单位";
    [_scrollV addSubview:_textDSF];
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(10, 260, SCREEN_WIDTH - 20, 1)];
    label2.layer.borderWidth = 1;
    label2.layer.borderColor = [[ UIColor lightGrayColor]CGColor];
    [_scrollV addSubview:label2];
    _textFMS = [[UITextView alloc]initWithFrame:CGRectMake(20, 280, SCREEN_WIDTH - 40, 50)];
    _textFMS.tag =5333;
    _textFMS.placeholder = @"请填写任务描述";
    [_scrollV addSubview:_textFMS];
    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(10, 330, SCREEN_WIDTH - 20, 1)];
    label3.layer.borderWidth = 1;
    label3.layer.borderColor = [[ UIColor lightGrayColor]CGColor];
    [_scrollV addSubview:label3];
    
    UILabel *labelYJSJ  = [[UILabel alloc]initWithFrame:CGRectMake(10, 330, (SCREEN_WIDTH - 20)/3 , 50)];
    labelYJSJ.text = @"预计完成时间:";
    labelYJSJ.font = [UIFont systemFontOfSize:15];
    labelYJSJ.textColor  = [UIColor redColor];
    [_scrollV addSubview:labelYJSJ];
    
    _overTimeBtn1 = [[UIButton alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 20) / 3  , 330, (SCREEN_WIDTH - 20) / 9*4 , 50)];
    UIImageView *tiemimageV1 = [[UIImageView alloc]initWithFrame:CGRectMake( _overTimeBtn1.bounds.size.width - 23, 18, 13, 13 )];
    tiemimageV1.image = [UIImage imageNamed:@"date_tab"];
    _overTimeBtn1.titleLabel.font = [UIFont systemFontOfSize:15];
    [_overTimeBtn1 addSubview:tiemimageV1];
    
    NSString *str  = [NSString stringWithFormat:@"%@",[NSDate date]];
    NSArray *arrayCurrentTime = [str componentsSeparatedByString:@" "];
    _timestr = [NSString stringWithFormat:@"%@ %@",arrayCurrentTime[0],arrayCurrentTime[1]];
    //NSLog(@"时间%@",timestr);
    [_overTimeBtn1 setTitle:_timestr forState:UIControlStateNormal];
    NSArray *arrayt1 = [_timestr componentsSeparatedByString:@" "];
    [_overTimeBtn1 setTitle:arrayt1[0] forState:UIControlStateNormal];
    [_overTimeBtn1 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [_overTimeBtn1 addTarget: self action:@selector(onyjshBtn1Click) forControlEvents:UIControlEventTouchUpInside];
    [_scrollV addSubview:_overTimeBtn1];
    
    _overTimeBtn2 = [[UIButton alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 20) / 3  + (SCREEN_WIDTH - 20) / 9*4 - 5 , 330, (SCREEN_WIDTH - 20) / 9*2 , 50)];
    UIImageView *tiemimageV = [[UIImageView alloc]initWithFrame:CGRectMake( _overTimeBtn2.bounds.size.width , 18, 13, 13 )];
    tiemimageV.image = [UIImage imageNamed:@"date_tab"];
    _overTimeBtn2.titleLabel.font = [UIFont systemFontOfSize:15];
    [_overTimeBtn2 addSubview:tiemimageV];

    //_overTimeBtn2.backgroundColor = [UIColor blueColor];
    [_overTimeBtn2 setTitle:arrayt1[1] forState:UIControlStateNormal];
    [_overTimeBtn2 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [_overTimeBtn2 addTarget: self action:@selector(onyjshBtn2Click) forControlEvents:UIControlEventTouchUpInside];
    [_scrollV addSubview:_overTimeBtn2];
    
    UILabel *labelPGSJ  = [[UILabel alloc]initWithFrame:CGRectMake(10, 380, (SCREEN_WIDTH - 20)/3 , 50)];
    labelPGSJ.text = @"派工  时间:";
    labelPGSJ.textColor  = [UIColor redColor];
    [_scrollV addSubview:labelPGSJ];
    
    _pgTimeBtn1 = [[UIButton alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 20) / 3  , 380, (SCREEN_WIDTH - 20) / 9*4 , 50)];
    UIImageView *tiemimageV3 = [[UIImageView alloc]initWithFrame:CGRectMake( _pgTimeBtn1.bounds.size.width - 23, 18, 13, 13 )];
    tiemimageV3.image = [UIImage imageNamed:@"date_tab"];
    _pgTimeBtn1.titleLabel.font = [UIFont systemFontOfSize:15];
    [_pgTimeBtn1 addSubview:tiemimageV3];
    //_pgTimeBtn1.backgroundColor = [UIColor redColor];
    NSString *timestr1 = [NSString stringWithFormat:@"%@",[NSDate date]];
    //NSLog(@"%@",timestr);
    [_pgTimeBtn1 setTitle:timestr1 forState:UIControlStateNormal];
    NSArray *arrayt2 = [timestr1 componentsSeparatedByString:@" "];
    [_pgTimeBtn1 setTitle:arrayt2[0] forState:UIControlStateNormal];
    [_pgTimeBtn1 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [_pgTimeBtn1 addTarget: self action:@selector(onpgshBtn1Click) forControlEvents:UIControlEventTouchUpInside];
    [_scrollV addSubview:_pgTimeBtn1];
    
    _pgTimeBtn2 = [[UIButton alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 20) / 3 + (SCREEN_WIDTH - 20) / 9*4 - 5 , 380, (SCREEN_WIDTH - 20) / 9*2 , 50)];
    UIImageView *tiemimageV4 = [[UIImageView alloc]initWithFrame:CGRectMake( _pgTimeBtn2.bounds.size.width , 18, 13, 13 )];
    tiemimageV4.image = [UIImage imageNamed:@"date_tab"];
    _pgTimeBtn2.titleLabel.font = [UIFont systemFontOfSize:15];
    [_pgTimeBtn2 addSubview:tiemimageV4];
    //_pgTimeBtn2.backgroundColor = [UIColor blueColor];
    [_pgTimeBtn2 setTitle:arrayt1[1] forState:UIControlStateNormal];
    [_pgTimeBtn2 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [_pgTimeBtn2 addTarget: self action:@selector(onpgshBtn2Click) forControlEvents:UIControlEventTouchUpInside];
    [_scrollV addSubview:_pgTimeBtn2];
    
//    提交按钮
    _Submit = [[UIButton alloc]initWithFrame:CGRectMake(20, 460, SCREEN_WIDTH - 40, 40)];
    [_Submit setTitle:@"提交" forState:UIControlStateNormal];
    _Submit.backgroundColor  = [UIColor colorWithRed:0 green:0.67 blue:0.65 alpha:1];
    [_Submit addTarget:self action:@selector(onSubmitCilck) forControlEvents:UIControlEventTouchUpInside];
    [_scrollV addSubview:_Submit];
    

    
}

-(void)onSubmitCilck{

    NSLog(@"label%@",_SLRLabel.text);
    if ([_SLRLabel.text isEqualToString:@""]){
        
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请填写受理人" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
        
    }else{
    NSLog(@"%@",self.taskAboutArray);
    NSMutableDictionary *parameters = [[NSMutableDictionary alloc]init];
    parameters[@"receiveId"] = self.idd;
    parameters[@"state"] = [self.taskAboutArray valueForKey:@"state"];
    parameters[@"jdlx"] = @"派单";
    parameters[@"title"] = _textF.text;
    parameters[@"type"] = [NSString stringWithFormat:@"%ld",_rightbutton.tag];
    parameters[@"level"] = [NSString stringWithFormat:@"%ld",_leftbutton.tag];
    parameters[@"receiver"] = _SLRLabel.text;
    parameters[@"followReceiver"] = @"";
    parameters[@"accountability"] = _textFZR.text;
    parameters[@"thirdPart"] = _textDSF.text;
    parameters[@"answerTime"] = _timestr;
    parameters[@"promiseTime"] = [NSString stringWithFormat:@"%@ %@",_overTimeBtn1.titleLabel.text,_overTimeBtn2.titleLabel.text];
    parameters[@"handleTime"] = [NSString stringWithFormat:@"%@ %@",_pgTimeBtn1.titleLabel.text,_pgTimeBtn2.titleLabel.text];
    parameters[@"content"] = _textFMS.text;
    parameters[@"createName"] = [GCMUserInfo instance].realName;
    parameters[@"taskTime"] = _timestr;
    NSLog(@"测试%@",parameters);
    [GCMTaskHttpRequst postDataWithParmerts:parameters WithUrl:TASKADD_URL Success:^(id obj, NSError *err) {
        NSLog(@"测试成功了%@",obj);
        NSLog(@"测试成功了");
    }];
    [self.navigationController popViewControllerAnimated:YES];
    }
    
}

//获取时间1
-(void)onyjshBtn1Click{
    
    HJDatePickerView * datePickerView = [[HJDatePickerView alloc]init];
    [datePickerView createDatePickerMode:UIDatePickerModeDate GetTime:^(NSString *time) {
        NSString *nstring = time;
        NSArray *array = [nstring componentsSeparatedByString:@" "];
        [_overTimeBtn1 setTitle:array[0] forState:UIControlStateNormal];
    }];
    
}
//获取时间2
-(void)onyjshBtn2Click{
    
    HJDatePickerView * datePickerView = [[HJDatePickerView alloc]init];
    [datePickerView createDatePickerMode:UIDatePickerModeDate GetTime:^(NSString *time) {
        NSString *nstring = time;
        NSArray *array = [nstring componentsSeparatedByString:@" "];
        [_overTimeBtn2 setTitle:array[0] forState:UIControlStateNormal];
    }];
    
}

//获取时间1
-(void)onpgshBtn1Click{
    
    HJDatePickerView * datePickerView = [[HJDatePickerView alloc]init];
    [datePickerView createDatePickerMode:UIDatePickerModeDate GetTime:^(NSString *time) {
        NSString *nstring = time;
        NSArray *array = [nstring componentsSeparatedByString:@" "];
        [_pgTimeBtn1 setTitle:array[0] forState:UIControlStateNormal];
    }];
    
}
//获取时间2
-(void)onpgshBtn2Click{
    
    HJDatePickerView * datePickerView = [[HJDatePickerView alloc]init];
    [datePickerView createDatePickerMode:UIDatePickerModeDate GetTime:^(NSString *time) {
        NSString *nstring = time;
        NSArray *array = [nstring componentsSeparatedByString:@" "];
        [_pgTimeBtn2 setTitle:array[0] forState:UIControlStateNormal];
    }];
    
}



#pragma mark--展示下拉菜单
-(void)onLeftbutton{
    
    __weak typeof(self)weakSelf=self;
    if (!_leftmuen) {
        
        _leftmuen=[[SCXCreateAlertView alloc]initWithNameArray:_yearArr andMenuOrigin:CGPointMake(50,_leftbutton.frame.origin.y + 50 + 64 ) andMenuWidth:(SCREEN_WIDTH - 100)/2 andHeight:40 andLayer:0 andTableViewBackGroundColor:[UIColor clearColor] andIsSharp:YES andType:kNavigationPop];
        _leftmuen.delegate = weakSelf;
        _leftmuen.tableViewDelegate=self;
        _leftmuen.dismiss=^(){
            [weakSelf.leftmuen removeFromSuperview];
            _leftmuen=nil;
        };
        [self.view addSubview:_leftmuen];
    }
    else{
        [_leftmuen dismissWithCompletion:^(SCXCreateAlertView *create){
            [_leftmuen removeFromSuperview];
            _leftmuen = nil;
        }];
    }
}

#pragma mark--自定义下拉菜单代理方法,点击下拉菜单某一行时候对应的响应时间，点击完成后试图要消失，用一个block通知；
-(void)tableViewDidSelectRowAtIndexPath:(NSIndexPath *)indexPath andPopType:(popType)popViewType{
    
    //改变导航栏文字
    if (popViewType == kNavigationPop) {
        [_leftbutton setTitle:_yearArr[indexPath.row] forState:UIControlStateNormal];
        NSLog(@"aaaa%@",_reciveFenleiArray);
        _leftbutton.tag = [[_reciveXiaoquArray[indexPath.row] valueForKey:@"id"] intValue];
    }
    [_leftmuen dismissWithCompletion:nil];//点击完成后视图消失;
    
    //    [GCMReviceHttpRequst postReciveListDataWithcourtId:[GCMUserInfo instance].areaId Withremark:@"1" WithPage:@"1" WithUserName:[GCMUserInfo instance].realName Success:^(id obj, NSError *err) {
    //        NSLog(@"+++%@",obj);
    //        _dataSource = obj;
    //        [_tableV reloadData];
    //    }];
    
}
#pragma mark---同上
-(void)onRightbutton{
    __weak typeof(self)weakSelf=self;
    if (!_rightmuen) {
        
        _rightmuen=[[SCXCreateAlertView2 alloc]initWithNameArray:_monthArr andMenuOrigin:CGPointMake((SCREEN_WIDTH - 50)/2 +60,_leftbutton.frame.origin.y + 50 +64 ) andMenuWidth:(SCREEN_WIDTH - 100)/2 andHeight:40 andLayer:0 andTableViewBackGroundColor:[UIColor clearColor] andIsSharp:YES andType:kNavigationPop2];
        _rightmuen.delegate = weakSelf;
        _rightmuen.tableViewDelegate=self;
        _rightmuen.dismiss=^(){
            [weakSelf.rightmuen removeFromSuperview];
            _rightmuen=nil;
        };
        [self.view addSubview:_rightmuen];
    }
    else{
        [_rightmuen dismissWithCompletion:^(SCXCreateAlertView2 *create) {
            [_rightmuen removeFromSuperview];
            _rightmuen = nil;
        }];
    }
}

-(void)secondtableViewDidSelectRowAtIndexPath:(NSIndexPath *)indexPath andPopType:(popType2)popViewType{
    
    //改变导航栏文字
    if (popViewType==kNavigationPop2) {
        [_rightbutton setTitle:_monthArr[indexPath.row] forState:UIControlStateNormal];
        _rightbutton.tag = [[_reciveFenleiArray[indexPath.row] valueForKey:@"id"] intValue];
    }
    
   // NSLog(@"%@%@",_yearArr1[indexPath.row],_monthArr1[indexPath.row]);
    //
    //    [GCMReviceHttpRequst postReciveListDataWithcourtId:_yearArr1[indexPath.row] Withremark:_monthArr1[indexPath.row] WithPage:@"1" WithUserName:[GCMUserInfo instance].realName Success:^(id obj, NSError *err) {
    //        NSLog(@"+++%@",obj);
    //        _dataSource = obj;
    //        [_tableV reloadData];
    //    }];
    
    
    
    
    [_rightmuen dismissWithCompletion:nil];//点击完成后视图消失;
}


-(void)onSLRBtnClick{

    GCMSLRViewController *main =[[GCMSLRViewController alloc]init];
    
    //3.设置回调的block
    main.returnStrBlock = ^(NSString * str){
        _SLRLabel.text = str;
        _SLRLabel.textColor = [UIColor lightGrayColor];
    };
    [self.navigationController pushViewController:main animated:YES];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
    backItem.title = @"成员选择";
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationItem.backBarButtonItem = backItem;

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
